package com.example.myapplication2;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class ForgetActivity extends AppCompatActivity implements View.OnClickListener {
    EditText passwordEditText2;
    EditText passwordEditText;
    EditText accountEdit2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String date = extras.getString("date");

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forget);
        passwordEditText2 = findViewById(R.id.passwordEditText2);
        passwordEditText  = findViewById(R.id.passwordEditText);
        accountEdit2  = findViewById(R.id.accountEdit2);
        accountEdit2.setText(date);
        findViewById(R.id.determine).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.determine:
                String s = passwordEditText.getText().toString();
                String s2 = passwordEditText2.getText().toString();
                if ((s!=null&&s2!=null)&&(s.equals(s2))){
                    Intent intent=new Intent();
                    Bundle bundle = new Bundle();
                    bundle.putString("message",s2);
                    intent.putExtras(bundle);
                    setResult(Activity.RESULT_OK,intent);
                    //返回
                    finish();
                }else {
                    Toast.makeText(this,"密码异常",Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}